package c.e.a.b.f.b;

import android.os.Bundle;
import android.os.SystemClock;
import c.e.a.b.b.j.c;
import c.e.a.b.e.c.t9;
import c.e.a.b.e.c.u9;
import c.e.a.b.e.c.x9;
import java.util.Objects;

/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
public final class d9 {
    public long a;
    public long b;
    public final i c;
    public final /* synthetic */ w8 d;

    public d9(w8 w8Var) {
        this.d = w8Var;
        this.c = new c9(this, w8Var.a);
        Objects.requireNonNull((c) w8Var.a.n);
        long elapsedRealtime = SystemClock.elapsedRealtime();
        this.a = elapsedRealtime;
        this.b = elapsedRealtime;
    }

    public final boolean a(boolean z, boolean z2, long j) {
        this.d.g();
        this.d.t();
        if (!(t9.a() && this.d.a.g.o(p.q0) && !this.d.a.i())) {
            h4 h4Var = this.d.l().u;
            Objects.requireNonNull((c) this.d.a.n);
            h4Var.b(System.currentTimeMillis());
        }
        long j2 = j - this.a;
        if (z || j2 >= 1000) {
            if (this.d.a.g.o(p.T) && !z2) {
                if (((x9) u9.b.q()).q() && this.d.a.g.o(p.V)) {
                    j2 = j - this.b;
                    this.b = j;
                } else {
                    j2 = b();
                }
            }
            this.d.d().n.b("Recording user engagement, ms", Long.valueOf(j2));
            Bundle bundle = new Bundle();
            bundle.putLong("_et", j2);
            h7.A(this.d.q().w(this.d.a.g.z().booleanValue() ^ 1), bundle, true);
            if (this.d.a.g.o(p.T) && !this.d.a.g.o(p.U) && z2) {
                bundle.putLong("_fr", 1);
            }
            if (!(this.d.a.g.o(p.U) && z2)) {
                this.d.n().H("auto", "_e", bundle);
            }
            this.a = j;
            this.c.c();
            this.c.b(3600000);
            return true;
        }
        this.d.d().n.b("Screen exposed for less than 1000 ms. Event not sent. time", Long.valueOf(j2));
        return false;
    }

    public final long b() {
        Objects.requireNonNull((c) this.d.a.n);
        long elapsedRealtime = SystemClock.elapsedRealtime();
        long j = elapsedRealtime - this.b;
        this.b = elapsedRealtime;
        return j;
    }
}
